<%--
  Created by IntelliJ IDEA.
  User: 李林
  Date: 2020/3/24
  Time: 23:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>ERP后台主页</title>
    <meta name="description" content="ERP后台主页">
    <meta name="keywords" content="ERP后台主页">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/iCheck/square/blue.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/morris/morris.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/datepicker/datepicker3.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/daterangepicker/daterangepicker.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/treeTable/jquery.treetable.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/treeTable/jquery.treetable.theme.default.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/select2/select2.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/colorpicker/bootstrap-colorpicker.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/css/bootstrap-markdown.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/adminLTE/css/AdminLTE.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/adminLTE/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/css/style.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/ionslider/ion.rangeSlider.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/ionslider/ion.rangeSlider.skinNice.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap-slider/slider.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/pages/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.css">
</head>

<body class="hold-transition skin-yellow-light sidebar-mini">

<div class="wrapper">

    <!-- 页面头部 -->
    <jsp:include page="../header.jsp"></jsp:include>
    <!-- 页面头部 /-->

    <!-- 导航侧栏 -->
    <jsp:include page="../aside.jsp"></jsp:include>
    <!-- 导航侧栏 /-->

    <!-- 内容区域 -->
    <div class="content-wrapper onjsp">

        <!-- 内容头部 -->
        <section class="content-header">
            <h1>
                修改员工信息界面
                <small>管理员</small>
            </h1>
            <ol class="breadcrumb">
                <%--<li><a href="main.jsp"><i class="fa fa-dashboard"></i> 首页</a></li>--%>
            </ol>
        </section>
        <!-- 正文区域 -->
        <section class="content">

            <div class="col-md-12">
                <div class="box box-info">

                    <div class="box-header with-border">
                        <h2 class="box-title">员工信息</h2>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <br>
                    <form class="form-horizontal" id="modifyForm">
                        <div class="box-body">
                            <div class="divcenter" style="width: 600px;margin: 0 auto;">
                                <input type="hidden" name="uid" value="${userInfo.uid}">
                                <div class="form-group">
                                    <label for="inputUsername" class="col-sm-2 control-label">用户名</label>
                                    <div class="col-sm-10">
                                        <input type="text" readonly class="form-control" id="inputUsername" name="username" value="${userInfo.username}">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="inputName" class="col-sm-2 control-label">姓名</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="inputName" name="username" value="${userInfo.name}">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">性别</label>
                                    <div class="col-sm-10">
                                        <div class="radio">
                                            <label><input type="radio" name="gender" value="1" ${userInfo.gender == 1?'checked':''} >男</label>
                                            <label><input type="radio" name="gender" value="2" ${userInfo.gender == 2?'checked':''}>女</label>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="inputEmail" class="col-sm-2 control-label">邮箱</label>
                                    <div class="col-sm-10">
                                        <input type="email" class="form-control" id="inputEmail" name="email" value="${userInfo.email != null?userInfo.email:'null'}">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="inputPhone" class="col-sm-2 control-label">手机号码</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="inputPhone" name="phoneNum" value="${userInfo.phoneNum!= null?userInfo.phoneNum:'null'}">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="datepicker" class="col-sm-2 control-label">日期</label>
                                    <div class="col-sm-10">
                                        <div class="input-group date">
                                            <div class="input-group-addon">
                                                <i class="fa fa-calendar"></i>
                                            </div>
                                            <input type="text" class="form-control pull-right" name="date"
                                                   value="<fmt:formatDate value='${userInfo.date}' pattern="yyyy-MM-dd"/>" id="datepicker">
                                        </div>
                                    </div>
                                </div>
                                <%--<c:forEach items="${userInfo.roles}" var="role"  varStatus="roleStatus">--%>
                                <%--<span>--%>
                                        <%--<c:if test="${roleStatus.last}">--%>
                                            <%--${role.roleDesc}--%>
                                        <%--</c:if>--%>
                                        <%--<c:if test="${!roleStatus.last}">--%>
                                            <%--${role.roleDesc}/--%>
                                        <%--</c:if>--%>
                                <%--</c:forEach><br>--%>
                                <%--</span>--%>
                                <div class="form-group">
                                    <label  class="col-sm-2 control-label">权限</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="inputAdmin" name="admin" value="${userInfo.roles[0].roleDesc}">
                                    </div>
                                </div>

                                <security:authorize access="hasRole('ROLE_MANAGER')">
                                    <div class="form-group">
                                        <%--<label class="col-sm-2 control-label" id="moduser_lab" onclick="showunstatus(${userInfo.uid})">修改权限</label>--%>
                                        <label class="col-sm-2 control-label" >
                                            <button type="button" id="moduser_lab" class="btn btn-default " onclick="showunstatus(${userInfo.uid})">修改权限</button></label>
                                        <div class="col-sm-10">
                                            <select style="margin-top: 6px" id="role_sel" name="wagesLevel"  class="form-control">
                                                <option value="0"><---点击修改权限</option>
                                            </select>
                                        </div>
                                    </div>
                                </security:authorize>
                            </div>
                            <!-- /.box-body -->
                            <div class="box-footer text-center">
                                <button type="button" class="btn btn-default " style="width: 82px" onclick="history.back(-1);">返回</button>
                                <button type="button" id="moduser_btn" class="btn btn-info" onclick="modifyuserdo()">修改信息</button>
                            </div>
                            <!-- /.box-footer -->
                        </div>
                    </form>

                </div>
            </div>
            <!--工具栏/-->
        </section>
        <!-- 正文区域 /-->


    </div>
    <!-- 内容区域 /-->

    <!-- 底部导航 -->
    <jsp:include page="../foot.jsp"></jsp:include>
    <!-- 底部导航 /-->

</div>


<script src="${pageContext.request.contextPath}/pages/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/jQueryUI/jquery-ui.min.js"></script>
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/raphael/raphael-min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/morris/morris.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/sparkline/jquery.sparkline.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/knob/jquery.knob.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/daterangepicker/moment.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/daterangepicker/daterangepicker.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/daterangepicker/daterangepicker.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/datepicker/bootstrap-datepicker.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/datepicker/locales/bootstrap-datepicker.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/fastclick/fastclick.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/iCheck/icheck.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/adminLTE/js/app.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/treeTable/jquery.treetable.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/select2/select2.full.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/js/bootstrap-markdown.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/locale/bootstrap-markdown.zh.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/js/markdown.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-markdown/js/to-markdown.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/ckeditor/ckeditor.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/input-mask/jquery.inputmask.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/input-mask/jquery.inputmask.extensions.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/chartjs/Chart.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/flot/jquery.flot.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/flot/jquery.flot.resize.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/flot/jquery.flot.pie.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/flot/jquery.flot.categories.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/ionslider/ion.rangeSlider.min.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-slider/bootstrap-slider.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-datetimepicker/bootstrap-datetimepicker.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/bootstrap-datetimepicker/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script src="${pageContext.request.contextPath}/pages/plugins/baiduTemplate/baiduTemplate.js"></script>
<script>
    $(document).ready(function() {
        // 选择框
        $(".select2").select2();

        // WYSIHTML5编辑器
        $(".textarea").wysihtml5({
            locale: 'zh-CN'
        });
    });


    // 设置激活菜单
    function setSidebarActive(tagUri) {
        var liObj = $("#" + tagUri);
        if (liObj.length > 0) {
            liObj.parent().parent().addClass("active");
            liObj.addClass("active");
        }
    }


    $(document).ready(function() {
        // 激活导航位置
        setSidebarActive("admin-index");
    });
</script>
</body>
</html>

<script>
    function modifyuserdo() {
        $.post("../usermodify.do",$("#modifyForm").serialize(),function (data) {
            alert(data.message);
            window.location.href = '../usershow';
        })
    }
    function modifyusersdo() {
        var select = $("#role_sel").val();
        if(select == null){
            alert("选择一个权限");
            return;
        }
        $.post("../usermodstatus.do",$("#modifyForm").serialize(),function (data) {
            alert(data.message);
            window.location.href = '../usershow';
        })
    }
    function showunstatus(uid) {
        // alert("123");
        $("#moduser_lab").removeAttr("onclick");
        $("#moduser_btn").removeAttr("onclick");
        $("#moduser_btn").click(modifyusersdo);
        $.post("../../role/roleall",{"uid":uid},function (resultMap) {
            var roles = resultMap.resultList["roles"];
            var ul = '';
            for (var i =0 ;i<roles.length ;i++){
                ul+= '<option class="role '+roles[i].roleName+'" value="'+roles[i].id+'">'+roles[i].roleDesc+'</option>';
            }
            $("#role_sel").html(ul);
            var useroles = resultMap.resultList["useroles"];
            for (var i = 0;i<useroles.length;i++){
                var tmp = document.getElementsByClassName(useroles[i].roleName);
                tmp[0].selected=true;
            }
        });
    }
</script>